package com.xsb.mvvmlibrary.dialog

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import com.xsb.mvvmlibrary.R
import kotlinx.android.synthetic.main.fragment_progress_dialog.*

/**
 *     author : 薛少博
 *     e-mail : xsb@zlhopesun.com
 *     time   : 2021/5/19
 *     desc   : 进度框
 */
class ProgressDialogFragment : DialogFragment() {
    private var message : String? = null
    companion object{
        fun newInstance() = ProgressDialogFragment()
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_progress_dialog,container,false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        tvMessage.text = message
    }

    fun show(fragmentManager: FragmentManager,messageRes : String,isCancelable:Boolean = false){
        this.message = messageRes
        this.isCancelable = isCancelable
        //show(fragmentManager,"ProgressDialogFragment")
    }
}